<?php
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use yii\widgets\LinkPager;
use frontend\controllers\MessageController;
use common\models\articles\Articles;
use common\models\member\Member;
use common\models\category\Category;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
    $tongzhi = Articles::find()->where(['category_id'=>18, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $zhengce = Articles::find()->where(['category_id'=>25, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $hangye = Articles::find()->where(['category_id'=>28, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $pinpai = Articles::find()->where(['category_id'=>23, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $xinwen = Articles::find()->where(['category_id'=>14, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
        // 会员风采
    $memberstyle = Member::find()->where(['status' => Member::STATUS_SUCCESS])->asArray()->limit(9)->all();
    $membersytletype = Category::find()->where(['id' =>20])->asArray()->one()['ctype'];

?>
<style>
#login_code{
    width: 2.0185rem;
    height: 0.99rem;
    vertical-align: middle;
    margin: 0 0.2rem;
}
</style>
    <!--位置-->
    <div class="clearFloat bag-fff">
        <div class="sewz m-l-35 m-r-35">
            <a href="<?= yii\helpers\Url::to(['/']);?>">首页</a> > 
            <a href="<?= yii\helpers\Url::to(['message/index', 'id' => 63]); ?>"><?= '留言板'; ?></a>
        </div>
    </div>
    <!--位置-->
    <!--列表-->
    <div class="clearFloat bag-fff">
        <div class="m-l-35 m-r-35">
            <div class="clearFloat">
                <h3 class="meh3">为了您的留言得到及时有效处理和回应，请填写真实信息。我们将严格保护
                    您的个人隐私。
                </h3>
                <div class="metabel">
                    <?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false, 'action' => 'sendpage' , 'method'=>'post' ]); ?>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>昵称：
                            </label>
                            <input type="text" class="neinput" id="user_dw" name="user">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>姓名：
                            </label>
                            <input type="text" class="neinput" id="user_name" name="name">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>联系电话：
                            </label>
                            <input type="text" class="neinput" id="user_phone" name="phone">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>电子邮件：
                            </label>
                            <input type="text" class="neinput" id="user_email" name="email">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                所在企业：
                            </label>
                            <input type="text" class="neinput" name="address">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>标题：
                            </label>
                            <input type="text" class="neinput" id="user_bt" name="title">
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>留言内容：
                            </label>
                            <textarea class="netext" placeholder="内容字数不超过200字" id="user_ly" name="content" maxlength="200"></textarea>
                        </div>
                        <div class="clearFloat metama">
                            <label class="nelabe">
                                <span class="text-c40400">*</span>验证码：
                            </label>
                            <span>
                                <input type="text" class="neinput" style="width:36%" id="user_yzm" name="code">
                                <?= Captcha::widget(['name'=>'verifyCode','captchaAction'=>'message/captcha','imageOptions'=>['id'=>'login_code', 'title'=>'换一个', 'alt'=>'换一个', 'style'=>''],'template'=>'{image}']);?>
                            </span>
                        </div>
                        <div class="clearFloat nesubdiv">
                            <input type="button" class="nesubm" value="提 交" onclick="mytry()">&nbsp;&nbsp;
                            <input type="reset" class="nesubm" value="重置信息" onclick="formReset()">
                        </div>
                    <?php ActiveForm::end(); ?>
                </div>
            </div>
        </div>
    </div>
    <!--列表-->
    <!--搜索-->
    <script>  
    function refreshCode(obj) {  
        var url = $(obj).attr('data-api');  
  
        if (url) {  
            $.ajax({  
                url: url + '?refresh',  
                dataType: 'json',  
                type: 'get',  
                success: function(data) {  
                    $(obj).attr('src', data.url);  
                }  
            });  
        }  
      }  
    $(function (){
        refreshCode('#login_code');  
  
        $('#login_code').click(function (event) {  
            event.preventDefault();  //阻止默认行为  
            event.stopPropagation(); //该方法将停止事件的传播，阻止它被分派到其他 Document 节点  
  
            refreshCode(this);  
        });  
  
    });  
</script>
<script>
function formReset()
{
    document.getElementById("myform").reset();
}
function mytry(){
    var user_dw=document.getElementById('user_dw').value;
    var user_name=document.getElementById('user_name').value;
    var user_phone=document.getElementById('user_phone').value;
    var user_email=document.getElementById('user_email').value;
    var user_bt=document.getElementById('user_bt').value;
    var user_ly=document.getElementById('user_ly').value;
    var user_yzm=document.getElementById('user_yzm').value;
    var numb=/^0?1[3|4|5|8][0-9]\d{8}$/;
    var reyrule=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; //邮箱
  
    if( user_dw==""){
       
        alert("对不起，昵称不能为空！");
        return false;
    }
    if(user_name==""){
        alert("对不起，姓名不能为空！");
        return false;
    }
    if(user_name.length<2||user_name.length>16){
        alert("对不起，姓名长度限制为：2-16位之间 ");
        return false;
    }
    if(user_phone==""){
        alert("对不起，电话不能为空！");
        return false;
    }
    if(!numb.test(user_phone)){
        alert("对不起，电话格式不正确！");
        return false;
    }
    if(user_email==""){
        alert("对不起，注册邮箱不能为空！");
        return false;
    }
    if (!reyrule.test(user_email)){
        alert("对不起，您输入的邮箱格式不正确！！");
        return false;
    }
    if(user_bt==""){
        alert("对不起，标题不能为空！");
        return false;
    }
    if(user_ly==""){
        alert("对不起，留言内容不能为空！");
        return false;
    }
    if(user_yzm==""){
        alert("对不起，验证码不能为空！");
        return false;
    }
    $('#login-form').submit();
}
</script>
